<%-- 
    Document   : login
    Created on : Feb 14, 2013, 5:31:29 PM
    Author     : SONY
--%>

<%@page import="javax.servlet.http.HttpServletRequest"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<% 
    if(session.getAttribute("user_admin") != null) {
        session.removeAttribute("user_admin"); 
    }            
%>
	<!--  start loginbox ................................................................................. -->
	<div id="loginbox">
            <p style=" margin-left: 100px;margin-bottom: 10px;"><i style='color:#db0958;'>${requestScope.errorMsg}</i></p>
	<!--  start login-inner -->
	<div id="login-inner">
            <form method='post' action='<c:url value="/admin/login.do" />'>
		<table border="0" cellpadding="0" cellspacing="0">
		<tr>
			<th>Email của bạn</th>
<% 
    String email = "";
    String password = "";
    Cookie[] allCookies = ((HttpServletRequest) request).getCookies(); 
    for(int i = 0; i < allCookies.length; i++) {
        if(allCookies[i].getName().equals("email_admin")) {
            email = allCookies[i].getValue();
        }
        if(allCookies[i].getName().equals("password_admin")) {
            password = allCookies[i].getValue();
        }
    }
    if(request.getAttribute("email") != null) {
        email = request.getAttribute("email").toString();
    }     
    if(request.getAttribute("password") != null) {
        password = request.getAttribute("password").toString();
    }     
%>                        
			<td><input type="text"  class="login-inp" name='email' value="<%=email%>"/></td>
		</tr>
		<tr>
			<th>Mật Khẩu</th>
			<td><input type="password" name='password' value="<%=password%>" class="login-inp"/></td>
		</tr>
		<tr>
			<th></th>
                        <td valign="top"><input type="checkbox" name="remember" value="checked" class="checkbox-size" id="login-check"  ${cookie.remember_admin.value}/>
                            <label for="login-check">Nhớ Tài Khoản</label></td>
		</tr>
		<tr>
			<th></th>
			<td style="padding-left: 50px;"><input type="submit" class="button lightText small regular black" name='login' value='Đăng Nhập' /></td>
		</tr>
		</table>
        </form>
	</div>
 	<!--  end login-inner -->
	<div class="clear"></div>
 </div>
 <!--  end loginbox -->

